<?php
/*
Plugin Name: USGS River Data 
Plugin URI: http://www.jtwventures.com
Description: This plugin gathers the water level, river name and other data from the USGS website and presents it in a way helpful for river guides and other fisherman to see relavent data. 
Author: J. Tyler Wiest
Version: 1.0
Author URI: http://www.jtwventures.com
License: GPLv2
*/

// Create River - Custom Post Type
include 'river_post_type.php';

// Add Taxonomies - State and Fish
include 'river_taxonomies.php';

// Add Custom Meta Box
include 'river_custom_meta.php';

// Create Short Code Information
include 'river_shortcode.php';

// Include the River Functions
include 'river_functions.php';

// Include Options Page
include 'river_options.php';

// Include Widget Settings
include 'river_widget.php';

// This will flish the rewrite rules on activation
register_activation_hook( __FILE__, 'river_activation_function' );

function river_activation_function() {
	riv_register_post_type();
	flush_rewrite_rules( false );
}

// Include Style Sheets
// Front End Styles
add_action('wp_enqueue_scripts', 'riv_load_css');
function riv_load_css() {
	$myStyleUrl = plugins_url('css/styles.css', __FILE__);
	$myStyleFile = WP_PLUGIN_DIR . '/river_data/css/styles.css';
	
	if ( file_exists($myStyleFile) ) {
	            wp_register_style('riv_css', $myStyleUrl);
	            wp_enqueue_style( 'riv_css');
	        }
	
}

// Admin Styles
add_action('admin_head', 'riv_admin_css');
function riv_admin_css() {
	$myStyleUrl = plugins_url('css/admin_styles.css', __FILE__);
	$myStyleFile = WP_PLUGIN_DIR . '/river_data/css/admin_styles.css';
	
	if ( file_exists($myStyleFile) ) {
	            wp_register_style('riv_css', $myStyleUrl);
	            wp_enqueue_style( 'riv_css');
	        }
	
}


// Activate Javascript with Page Detection
add_action('admin_print_scripts-post.php', 'usgs_river_number_validation_script');
add_action('admin_print_scripts-post-new.php', 'usgs_river_number_validation_script');

function usgs_river_number_validation_script() {
	wp_enqueue_script( 'usgs-river-validation', 
		plugins_url('/river_data/javascript/river_num_sanitize.js'), 
		array('jquery')
		);
}
?>